<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 解决异步回调的问题
        let a = 10;

        let pro = new Promise(function(resolve, reject) {
            // resolve 成功调用
            // reject 失败调用
            if (a == 10) {
                resolve('成功')
            } else {
                reject('失败')
            }
        });
        // pro.then(success,fail)
        pro.then(res => {
            console.log(res);
        }, err => {
            console.log(err);
        })

        // ---------------------------------------------------------
    </script>
</body>

</html>